home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / asetof1a / usercont.ctl < prev   
Text File  |  1999-10-21  |  7KB  |  210 lines

  1. VERSION 5.00
  2. Begin VB.UserControl Text 
  3.    ClientHeight    =   3600
  4.    ClientLeft      =   0
  5.    ClientTop       =   0
  6.    ClientWidth     =   4800
  7.    ScaleHeight     =   3600
  8.    ScaleWidth      =   4800
  9.    Begin VB.Timer timer 
  10.       Interval        =   1
  11.       Left            =   2430
  12.       Top             =   1650
  13.    End
  14.    Begin VB.TextBox Text1 
  15.       BackColor       =   &H00000000&
  16.       BorderStyle     =   0  'None
  17.       ForeColor       =   &H00E0E0E0&
  18.       Height          =   390
  19.       Left            =   270
  20.       TabIndex        =   0
  21.       Top             =   180
  22.       Width           =   3555
  23.    End
  24.    Begin VB.Shape Shape1 
  25.       BorderColor     =   &H00808080&
  26.       BorderWidth     =   2
  27.       Height          =   210
  28.       Left            =   540
  29.       Top             =   975
  30.       Width           =   1725
  31.    End
  32. End
  33. Attribute VB_Name = "Text"
  34. Attribute VB_GlobalNameSpace = False
  35. Attribute VB_Creatable = True
  36. Attribute VB_PredeclaredId = False
  37. Attribute VB_Exposed = True
  38. 'Default Property Values:
  39. Const m_def_BackColor = 0
  40. Const m_def_ForeColor = 0
  41. Const m_def_Enabled = 0
  42. Const m_def_BackStyle = 0
  43. Const m_def_BorderStyle = 0
  44. Const m_def_Text = ""
  45. 'Property Variables:
  46. Dim m_BackColor As Long
  47. Dim m_ForeColor As Long
  48. Dim m_Enabled As Boolean
  49. Dim m_Font As Font
  50. Dim m_BackStyle As Integer
  51. Dim m_BorderStyle As Integer
  52. Dim m_Text As String
  53. 'Event Declarations:
  54. Event Click()
  55. Attribute Click.VB_Description = "Occurs when the user presses and then releases a mouse button over an object."
  56. Event DblClick()
  57. Attribute DblClick.VB_Description = "Occurs when the user presses and releases a mouse button and then presses and releases it again over an object."
  58. Event KeyDown(KeyCode As Integer, Shift As Integer)
  59. Attribute KeyDown.VB_Description = "Occurs when the user presses a key while an object has the focus."
  60. Event KeyPress(KeyAscii As Integer)
  61. Attribute KeyPress.VB_Description = "Occurs when the user presses and releases an ANSI key."
  62. Event KeyUp(KeyCode As Integer, Shift As Integer)
  63. Attribute KeyUp.VB_Description = "Occurs when the user releases a key while an object has the focus."
  64. Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  65. Attribute MouseDown.VB_Description = "Occurs when the user presses the mouse button while an object has the focus."
  66. Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  67. Attribute MouseMove.VB_Description = "Occurs when the user moves the mouse."
  68. Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  69. Attribute MouseUp.VB_Description = "Occurs when the user releases the mouse button while an object has the focus."
  70.  
  71. Private Function UnderMouse() As Boolean
  72.     Dim ptMouse As POINTAPI
  73.     GetCursorPos ptMouse
  74.     If WindowFromPoint(ptMouse.X, ptMouse.Y) = Text1.hWnd Then
  75.        UnderMouse = True
  76.     Else
  77.        UnderMouse = False
  78.     End If
  79. End Function
  80.  
  81. Public Property Get BackColor() As Long
  82. Attribute BackColor.VB_Description = "Returns/sets the background color used to display text and graphics in an object."
  83.     BackColor = m_BackColor
  84. End Property
  85.  
  86. Public Property Let BackColor(ByVal New_BackColor As Long)
  87.     m_BackColor = New_BackColor
  88.     PropertyChanged "BackColor"
  89. End Property
  90.  
  91. Public Property Get ForeColor() As Long
  92. Attribute ForeColor.VB_Description = "Returns/sets the foreground color used to display text and graphics in an object."
  93.     ForeColor = m_ForeColor
  94. End Property
  95.  
  96. Public Property Let ForeColor(ByVal New_ForeColor As Long)
  97.     m_ForeColor = New_ForeColor
  98.     PropertyChanged "ForeColor"
  99. End Property
  100.  
  101. Public Property Get Enabled() As Boolean
  102. Attribute Enabled.VB_Description = "Returns/sets a value that determines whether an object can respond to user-generated events."
  103.     Enabled = m_Enabled
  104. End Property
  105.  
  106. Public Property Let Enabled(ByVal New_Enabled As Boolean)
  107.     m_Enabled = New_Enabled
  108.     PropertyChanged "Enabled"
  109. End Property
  110.  
  111. Public Property Get Font() As Font
  112. Attribute Font.VB_Description = "Returns a Font object."
  113. Attribute Font.VB_UserMemId = -512
  114.     Set Font = m_Font
  115. End Property
  116.  
  117. Public Property Set Font(ByVal New_Font As Font)
  118.     Set m_Font = New_Font
  119.     PropertyChanged "Font"
  120. End Property
  121.  
  122. Public Property Get BackStyle() As Integer
  123. Attribute BackStyle.VB_Description = "Indicates whether a Label or the background of a Shape is transparent or opaque."
  124.     BackStyle = m_BackStyle
  125. End Property
  126.  
  127. Public Property Let BackStyle(ByVal New_BackStyle As Integer)
  128.     m_BackStyle = New_BackStyle
  129.     PropertyChanged "BackStyle"
  130. End Property
  131.  
  132. Public Property Get BorderStyle() As Integer
  133. Attribute BorderStyle.VB_Description = "Returns/sets the border style for an object."
  134.     BorderStyle = m_BorderStyle
  135. End Property
  136.  
  137. Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
  138.     m_BorderStyle = New_BorderStyle
  139.     PropertyChanged "BorderStyle"
  140. End Property
  141.  
  142. Public Sub Refresh()
  143. Attribute Refresh.VB_Description = "Forces a complete repaint of a object."
  144.      
  145. End Sub
  146.  
  147. Public Property Get Text() As String
  148. Attribute Text.VB_Description = "Returns/sets the text contained in the control."
  149.     Text = m_Text
  150. End Property
  151.  
  152. Public Property Let Text(ByVal New_Text As String)
  153.     m_Text = New_Text
  154.     PropertyChanged "Text"
  155. End Property
  156.  
  157. 'Initialize Properties for User Control
  158. Private Sub UserControl_InitProperties()
  159.     m_BackColor = m_def_BackColor
  160.     m_ForeColor = m_def_ForeColor
  161.     m_Enabled = m_def_Enabled
  162.     Set m_Font = Ambient.Font
  163.     m_BackStyle = m_def_BackStyle
  164.     m_BorderStyle = m_def_BorderStyle
  165.     m_Text = m_def_Text
  166.     Runtime
  167. End Sub
  168. Private Sub timer_Timer()
  169. If UnderMouse = True Then
  170.    Text1.BackColor = &H800000
  171.    Else
  172.    Text1.BackColor = vbBlack
  173. End If
  174. End Sub
  175. 'Load property values from storage
  176. Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  177.  
  178.     m_BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
  179.     m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
  180.     m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
  181.     Set m_Font = PropBag.ReadProperty("Font", Ambient.Font)
  182.     m_BackStyle = PropBag.ReadProperty("BackStyle", m_def_BackStyle)
  183.     m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
  184.     m_Text = PropBag.ReadProperty("Text", m_def_Text)
  185. End Sub
  186.  
  187. Private Sub UserControl_Resize()
  188. Shape1.Move 0, 0, UserControl.ScaleWidth, UserControl.ScaleHeight
  189. Text1.Move 12, 12, (UserControl.Width - 26), (UserControl.Height - 26)
  190. End Sub
  191.  
  192. 'Write property values to storage
  193. Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
  194.  
  195.     Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)
  196.     Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
  197.     Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)
  198.     Call PropBag.WriteProperty("Font", m_Font, Ambient.Font)
  199.     Call PropBag.WriteProperty("BackStyle", m_BackStyle, m_def_BackStyle)
  200.     Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
  201.     Call PropBag.WriteProperty("Text", m_Text, m_def_Text)
  202. End Sub
  203.  
  204. Private Function Runtime()
  205. If Ambient.UserMode Then
  206.        Timer.Enabled = True
  207.     Else: Timer.Enabled = False
  208. End If
  209. End Function
  210.